package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.BdmOrderShipments;
import com.ruoyi.system.enums.BdmOrderShipmentsEnum;
import com.ruoyi.system.mapper.BdmOrderShipmentsMapper;
import com.ruoyi.system.service.IBdmOrderShipmentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单发货Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-28
 */
@Service
public class BdmOrderShipmentsServiceImpl extends ServiceImpl<BdmOrderShipmentsMapper,BdmOrderShipments> implements IBdmOrderShipmentsService
{
    @Autowired
    private BdmOrderShipmentsMapper bdmOrderShipmentsMapper;

    /**
     * 查询订单发货
     * 
     * @param id 订单发货主键
     * @return 订单发货
     */
    @Override
    public BdmOrderShipments selectBdmOrderShipmentsById(Long id)
    {
        return bdmOrderShipmentsMapper.selectBdmOrderShipmentsById(id);
    }

    /**
     * 查询订单发货列表
     * 
     * @param bdmOrderShipments 订单发货
     * @return 订单发货
     */
    @Override
    public List<BdmOrderShipments> selectBdmOrderShipmentsList(BdmOrderShipments bdmOrderShipments)
    {
        return bdmOrderShipmentsMapper.selectBdmOrderShipmentsList(bdmOrderShipments);
    }

    /**
     * 新增订单发货
     * 
     * @param bdmOrderShipments 订单发货
     * @return 结果
     */
    @Override
    public int insertBdmOrderShipments(BdmOrderShipments bdmOrderShipments)
    {
        bdmOrderShipments.setCreateTime(DateUtils.getNowDate());
        return bdmOrderShipmentsMapper.insertBdmOrderShipments(bdmOrderShipments);
    }

    /**
     * 修改订单发货
     * 
     * @param bdmOrderShipments 订单发货
     * @return 结果
     */
    @Override
    public int updateBdmOrderShipments(BdmOrderShipments bdmOrderShipments)
    {
        bdmOrderShipments.setUpdateTime(DateUtils.getNowDate());
        return bdmOrderShipmentsMapper.updateBdmOrderShipments(bdmOrderShipments);
    }

    /**
     * 批量删除订单发货
     * 
     * @param ids 需要删除的订单发货主键
     * @return 结果
     */
    @Override
    public int deleteBdmOrderShipmentsByIds(Long[] ids)
    {
        return bdmOrderShipmentsMapper.deleteBdmOrderShipmentsByIds(ids);
    }

    /**
     * 删除订单发货信息
     * 
     * @param id 订单发货主键
     * @return 结果
     */
    @Override
    public int deleteBdmOrderShipmentsById(Long id)
    {
        return bdmOrderShipmentsMapper.deleteBdmOrderShipmentsById(id);
    }

    /**
     * 新增订单操作日志
     * @param orderId 订单号
     * @param message 日志
     * @param userId  用户id
     * @param userName 用户名称
     */
    @Override
    public void saveBdmOrderShipments(List<BdmOrderShipments> bdmOrderShipments) {

        this.saveBatch(bdmOrderShipments);
    }

    @Override
    public List<BdmOrderShipments> selectBdmOrderShipmentsAfterSaleList(BdmOrderShipments bdmOrderShipments) {
        bdmOrderShipments.setOrderStatus(BdmOrderShipmentsEnum.CUSTOMER_REFUND.getType());
        return bdmOrderShipmentsMapper.selectBdmOrderShipmentsAfterSaleList(bdmOrderShipments);
    }
}
